Translation method and electronic device

ABSTRACT

A translation method includes: a first electronic device establishes a call connection to a second electronic device and then displays a call interface; after receiving a first operation of a first user, the first electronic device switches from displaying the call to displaying a translation interface; when receiving a first speech of the first user in a first language, the translation interface sequentially displays at least a first text and a second text, where the first text is obtained by recognizing the first speech, and the second text is obtained by translating the first speech into a target language; and the first electronic device sends a machine speech in the target language to the second electronic device.

CROSS-REFERENCE TO RELATED APPLICATIONS

This is a continuation of U.S. patent application Ser. No. 17/285,632filed on Apr. 15, 2021, which is a national stage of InternationalPatent Application No. PCT/CN2019/111130 filed on Oct. 15, 2019, whichclaims priority to Chinese Patent Application No. 201811198981.X filedon Oct. 15, 2018. All of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the field of terminal technologies, and inparticular, to a translation method and an electronic device.

BACKGROUND

In recent years, with rapid development of the electronics industry andcommunications technologies, there is an increasing quantity of smarthome devices, for example, mobile phones, smart speakers, and smartbands, and people's life becomes increasingly intelligent. Due toportability of the mobile phones and an ability to download applicationsoftware with various functions from an application store, the mobilephones have become an indispensable necessity in people's daily life.

With continuous development and progress of trade and communicationbetween countries, the trend of user internationalization inevitablyleads to a problem of poor communication between people speakingdifferent languages. Taking a call between users who are native speakersof Chinese and English as an example, a user who uses Chinese needs tobe proficient in English to communicate with an English user, and fewEnglish users understand Chinese. Therefore, a language becomes abiggest obstacle to international communication, and a need for instantlanguage translation during a call becomes increasingly important.

Although instant language translation can be performed during a call, ifa language type needs to be switched, the call needs to be interrupted,and a call is initiated again after the language type is successfullyset. In addition, a delay exists in a translation process. As a result,a post-translation machine speech may overlap with a user's speechduring the call.

SUMMARY

This application provides a translation method and an electronic device,so that two parties in a call who use different languages can achievesmooth and real-time verbal communication by using a translationfunction of the electronic device.

According to a first aspect, an embodiment of this application providesa translation method, where the method is applicable to a firstelectronic device, and the method includes: The first electronic deviceestablishes a call connection to a second electronic device and displaysa call interface of the first electronic device; then the firstelectronic device receives a first operation of a first user; inresponse to the first operation, the first electronic device switchesfrom displaying the call interface to displaying a translationinterface; then the first electronic device receives a first speech ofthe first user in a first language and sends the first speech to thesecond electronic device; in response to the first speech, thetranslation interface of the first electronic device sequentiallydisplays at least a first text and a second text, where the first textis obtained by recognizing the first speech, and the second text isobtained by translating the first speech into a target language; andwhen the translation interface displays the second text, the firstelectronic device sends a machine speech in the target language to thesecond electronic device, where the machine speech in the targetlanguage is obtained by translating the first speech into the targetlanguage. According to this method, a machine speech and a text that arein a target language can be synchronized, so as to avoid a problem thata user has completed reading a post-translation text but a machinespeech has not been received yet.

Further, the first electronic device receives a language settingoperation performed by the first user on the translation interface; inresponse to the language setting operation, the first electronic deviceswitches from displaying the translation interface to displaying alanguage settings interface, where the language settings interfaceincludes a setting control of a second language; the first electronicdevice receives a confirmation operation performed by the first user onthe setting control of the second language; in response to theconfirmation operation, the first electronic device sets the targetlanguage to the second language; then the first electronic devicereceives an on-hook operation performed by the first user on the callinterface; and in response to the on-hook operation, the firstelectronic device terminates the call connection. In this method, alanguage setting can be changed during a call, so that a translationfunction is more user-friendly.

In a possible design, the first electronic device may obtain aninternational area code from a phone number dialed by the first user,and then based on the international area code, set the target languageto an official language of a country corresponding to the internationalarea code. In other words, the first electronic device may automaticallyset a target language without a manual operation of a user, so that thetranslation function is more user-friendly.

In a possible design, after in response to the first speech, and beforethe translation interface sequentially displays at least the first textand the second text, the method further includes: obtaining the firsttext by recognizing the first speech, and translating the first textinto the second text in the target language; and converting the secondtext into the machine speech in the target language. In other words, inthis embodiment of this application, a user speech can be translated byusing the foregoing method. Both a text and a machine speech areobtained through translation, so that a user can easily understand callcontent of the other party.

In a possible design, the method further includes: The first electronicdevice receives a second speech of the first user in the target languageand sends the second speech to the second electronic device; then thefirst electronic device receives a close operation performed by thefirst user on a control of reading self-translation on the translationinterface; and in response to the close operation, the electronic devicedisplays the translation interface, where the translation interfacefurther includes a third text in the target language, and the third textis obtained by recognizing the second speech.

In this embodiment of this application, a user independently enables ordisables a translation function of the user's own speech, so thatinvalid translation can be reduced, and call smoothness can be improved.

In a possible design, the method further includes: The first electronicdevice receives a second speech of the first user in the target languageand sends the second speech to the second electronic device; whendetecting that a language corresponding to the second speech is thetarget language, in response to the second speech, the electronic deviceskips translating the second speech and displays the translationinterface, where the translation interface further includes a third textin the target language.

In this embodiment of this application, a translation function of auser's own speech is automatically disabled, so that invalid translationcan be reduced, and call smoothness can be improved.

In a possible design, after the first electronic device sends themachine speech in the target language to the second electronic deviceand before the first electronic device receives the on-hook operationperformed by the first user on the call interface, the method furtherincludes: receiving a third speech that is in the target language andthat is sent by the second electronic device; in response to the thirdspeech, displaying the translation interface, where the translationinterface further includes a fourth text in the target language and afifth text in the first language, the fourth text in the target languageis obtained by recognizing the third speech, and the fifth text in thefirst language is obtained by translating the third speech into thetarget language; and when the first electronic device receives a machinespeech that is in the first language and that is sent by the secondelectronic device, displaying the fifth text on the translationinterface, where the machine speech in the first language is obtained bytranslating the third speech into the target language.

In this embodiment of this application, the first electronic device mayreceive a speech and a machine speech that are sent by a peer user,thereby implementing smooth and real-time verbal communication.

In a possible design, the first electronic device plays, by using anearpiece of the first electronic device, the third speech that is in thetarget language and that is sent by the second electronic device; andafter the first electronic device receives the machine speech that is inthe first language and that is sent by the second electronic device, andbefore the first electronic device receives the on-hook operationperformed by the first user on the call interface, the method furtherincludes: playing the machine speech in the first language by using aspeaker of the first electronic device. The method may help a userunderstand call content of a peer user in different scenarios.

In a possible design, before the first electronic device receives theon-hook operation performed by the first user on the call interface, themethod further includes: receiving a close operation performed by thefirst user on a mute control on the translation interface; and inresponse to the close operation, stopping playing the machine speech inthe first language. In this way, the translation function may be moreuser-friendly, thereby improving user experience.

In a possible design, when the first electronic device plays the machinespeech in the first language by using the speaker of the firstelectronic device, the method further includes: receiving a fourthspeech of the first user in the first language; and in response to thefourth speech, displaying prompt information, where the promptinformation is used to instruct the first user to send a speech afterthe machine speech in the first language is played. Using the method,when a user speaks excessively fast, or an interval between consecutivespeeches sent by the user is excessively short, the electronic devicemay display prompt information on the translation interface, to remindthe user to slow down a speaking rate, so as to avoid overlappingbetween a machine speech and the user's speech.

In a possible design, the method further includes: receiving an exitoperation performed by the first user on the translation interface; inresponse to the exit operation, switching from displaying thetranslation interface to displaying the call interface; receiving afifth speech of the first user in the first language; and sending thefifth speech to the second electronic device. In this way, it isconvenient for a user to enable the translation function according to anactual requirement, which is more user-friendly and personalized andimproves user experience.

According to a second aspect, an embodiment of this application providesan electronic device, including a processor and a memory. The memory isconfigured to store one or more computer programs. When the one or morecomputer programs stored in the memory are executed by the processor,the electronic device is enabled to implement the method in any one ofthe possible designs in any one of the foregoing aspects.

According to a third aspect, an embodiment of this application furtherprovides an apparatus. The apparatus includes modules/units forperforming the method in any one of the possible designs in any one ofthe foregoing aspects. These modules/units may be implemented byhardware, or may be implemented by hardware by executing correspondingsoftware.

According to a fourth aspect, an embodiment of this application furtherprovides a computer-readable storage medium, where the computer-readablestorage medium includes a computer program. When the computer program isrun on an electronic device, the electronic device performs the methodin any one of the possible designs in any one of the foregoing aspects.

According to a fifth aspect, an embodiment of this application furtherprovides a computer program product. When the computer program productis run on a terminal, the electronic device performs the method in anyone of the possible designs in any one of the foregoing aspects.

These aspects or other aspects of this application are more concise andunderstandable in the following descriptions of embodiments.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of an interconnection scenario accordingto an embodiment of this application;

FIG. 2 is a schematic structural diagram of a mobile phone according toan embodiment of this application;

FIG. 3 is a schematic structural diagram of an Android operating systemaccording to an embodiment of this application;

FIG. 4A to FIG. 4E are schematic diagrams of a group of interfacesaccording to an embodiment of this application;

FIG. 4F to FIG. 4J are schematic diagrams of another group of interfacesaccording to an embodiment of this application;

FIG. 5 is a schematic diagram of an interface according to an embodimentof this application;

FIG. 6 is a schematic diagram of an interface according to an embodimentof this application;

FIG. 7A to FIG. 7D are a schematic diagram of a group of interfacesaccording to an embodiment of this application;

FIG. 8 is a schematic diagram of an interface according to an embodimentof this application;

FIG. 9 is a schematic diagram of an interface according to an embodimentof this application;

FIG. 10 is a schematic structural diagram of an electronic deviceaccording to an embodiment of this application; and

FIG. 11 is a schematic structural diagram of another electronic deviceaccording to an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

For ease of understanding, descriptions of some concepts related toembodiments of this application are provided as examples for reference,as shown in the following.

Machine translation, also referred to as automatic translation, is aprocess of converting one natural language (source language) intoanother natural language (target language) by using a computer.

The following describes the technical solutions in the embodiments ofthis application with reference to the accompanying drawings in theembodiments of this application. In the following descriptions of theembodiments of this application, terms “first” and “second” are merelyused for a purpose of descriptions, and shall not be understood as anindication or implication of relative importance or an implicitindication of a quantity of indicated technical features. Therefore, afeature limited by “first” or “second” may explicitly or implicitlyinclude one or more features. A first language and a second language inthe following refer to natural languages, and a first speech and asecond speech refer to sounds made by a user. In the description of theembodiment of this application, unless otherwise stated, “multiple”means two or more than two.

The translation method provided in the embodiments of this applicationmay be applied to a scenario shown in FIG. 1 in which a plurality ofelectronic devices 100 is interconnected based on a communicationsnetwork. The communications network may be a local area network, or maybe a wide area network switched by using a relay device. When thecommunications network is a local area network, for example, thecommunications network may be a short-distance communications networksuch as a WiFi hotspot network, a WiFi P2P network, a Bluetooth network,a ZigBee network, or a near field communication (near fieldcommunication, NFC) network. When the communications network is a widearea network, for example, the communications network may be athird-generation mobile communications technology (3rd-generationwireless telephone technology, 3G) network, a fourth-generation mobilecommunications technology (the 4th generation mobile communicationtechnology, 4G) network, a fifth-generation mobile communicationstechnology (5th-generation mobile communication technology, 5G) network,a future evolved public land mobile network (public land mobile network,PLMN), or the Internet. In the scenario shown in FIG. 1 , differentelectronic devices may exchange data by using the communicationsnetwork, for example, exchange a picture, a text, and a video, orexchange a result obtained after the electronic devices process anobject such as a picture, a text, or a video.

In some embodiments of this application, the electronic device 100 shownin FIG. 1 may be a portable electronic device that further includesanother function such as a personal digital assistant function and/or amusic player function, for example, a mobile phone, a tablet computer,or a wearable device (such as a smartwatch) having a wirelesscommunication function. An example embodiment of a portable electronicdevice includes but is not limited to a portable electronic device usingiOS®, Android®, Microsoft®, or another operating system. The portableelectronic device may also be another portable electronic device, suchas a laptop computer (laptop) having a touch-sensitive surface (forexample, a touch panel). It may be further understood that in some otherembodiments of this application, the electronic device 100 mayalternatively not be a portable electronic device, but a desktopcomputer having a touch-sensitive surface (for example, a touch panel).

For example, as shown in FIG. 2 , the following uses the electronicdevice 100 as an example to specifically describe an embodiment.

The electronic device 100 may include a processor 110, an externalmemory interface 120, an internal memory 121, a USB interface 130, acharging management module 140, a power management module 141, a battery142, an antenna 1, an antenna 2, a mobile communications module 150, awireless communications module 160, an audio module 170, a speaker 170A,a receiver 170B, a microphone 170C, a headset jack 170D, a sensor module180, a key 190, a motor 191, an indicator 192, a camera 193, a displayscreen 194, a SIM card interface 195, and the like. The sensor module180 may include a pressure sensor 180A, a gyro sensor 180B, a barometricpressure sensor 180C, a magnetic sensor 180D, an acceleration sensor180E, a distance sensor 180F, a proximity light sensor 180G, afingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K,an ambient light sensor 180L, a bone conduction sensor 180M, and thelike.

It should be understood that a structure illustrated in this embodimentof the present disclosure does not constitute a specific limitation onthe electronic device 100. In some other embodiments of thisapplication, the electronic device 100 may include more or fewercomponents than those shown in the figure, or combine some components,or split some components, or have different component arrangements. Thecomponents shown in the figure may be implemented by hardware, software,or a combination of software and hardware.

The processor 110 may include one or more processing units. For example,the processor 110 may include an application processor (applicationprocessor, AP), a modem processor, a graphics processing unit (graphicsprocessing unit, GPU), an image signal processor (image signalprocessor, ISP), a controller, a memory, a video codec, a digital signalprocessor (digital signal processor, DSP), a baseband processor, and/ora neural network processor (Neural-network Processing Unit, NPU).Different processing units may be independent devices, or may beintegrated into one or more processors.

The controller may be a nerve center and a command center of theelectronic device 100. The controller may generate an operation controlsignal according to instruction operation code and a timing signal, soas to complete control of fetching an instruction and executing aninstruction.

The memory may further be disposed in the processor 110 and isconfigured to store an instruction and data. In some embodiments, thememory in the processor 110 is a cache. The memory may store aninstruction or data that has just been used or cyclically used by theprocessor 110. If the processor 110 needs to use the instruction or thedata again, the instruction or the data may be directly invoked from thememory, which avoids repeated access, reduces a waiting time of theprocessor 110, and therefore improves system efficiency.

In some embodiments, the processor 110 may include one or moreinterfaces. The interface may include an inter-integrated circuit(inter-integrated circuit, I2C) interface, an inter-integrated circuitsound (inter-integrated circuit sound, I2S) interface, a pulse codemodulation (pulse code modulation, PCM) interface, a universalasynchronous receiver/transmitter (universal asynchronousreceiver/transmitter, UART) interface, a mobile industry processorinterface (mobile industry processor interface, MIPI), a general purposeinput/output (general-purpose input/output, GPIO) interface, asubscriber identity module (subscriber identity module, SIM) interface,a universal serial bus (universal serial bus, USB) interface, and/or thelike.

The I2C interface is a bidirectional synchronous serial bus, includingone serial data line (serial data line, SDA) and one serial clock line(derail clock line, SCL). In some embodiments, the processor 110 mayinclude a plurality of groups of I2C buses. The processor 110 may beseparately coupled to the touch sensor 180K, a charger, a camera flash,the camera 193, and the like by using different I2C bus interfaces. Forexample, the processor 110 may be coupled to the touch sensor 180K byusing an I2C interface, so that the processor 110 communicates with thetouch sensor 180K by using the I2C bus interface, thereby implementing atouch function of the electronic device 100.

The I2S interface may be used for audio communication. In someembodiments, the processor 110 may include a plurality of groups of I2Sbuses. The processor 110 may be coupled to the audio module 170 by usingthe I2S bus, thereby implementing communication between the processor110 and the audio module 170. In some embodiments, the audio module 170may send an audio signal to the wireless communications module 160 byusing the I2S interface, thereby implementing a function of answering acall through a Bluetooth headset.

The PCM interface may also be used for audio communication, sampling,quantizing, and encoding an analog signal. In some embodiments, theaudio module 170 and the wireless communications module 160 may becoupled by using the PCM bus interface. In some embodiments, the audiomodule 170 may also send an audio signal to the wireless communicationsmodule 160 by using the PCM interface, thereby implementing the functionof answering a call through a Bluetooth headset. Both the I2S interfaceand the PCM interface may be used for audio communication.

The UART interface is a universal serial data bus used for asynchronouscommunication. The bus may be a bidirectional communications bus thatconverts to-be-transmitted data between serial communication andparallel communication. In some embodiments, the UART interface isusually configured to connect the processor 110 and the wirelesscommunications module 160. For example, the processor 110 communicateswith a Bluetooth module in the wireless communications module 160 byusing the UART interface, thereby implementing a Bluetooth function. Insome embodiments, the audio module 170 may send an audio signal to thewireless communications module 160 by using the UART interface, therebyimplementing a function of playing music through a Bluetooth headset.

The MIPI interface may be configured to connect the processor 110 to aperipheral device such as the display screen 194 or the camera 193. TheMIPI interface includes a camera serial interface (camera serialinterface, CSI), a display serial interface (display serial interface,DSI), and the like. In some embodiments, the processor 110 communicateswith the camera 193 by using the CSI interface, thereby implementing aphotographing function of the electronic device 100. The processor 110communicates with the display screen 194 by using the DSI interface,thereby implementing a display function of the electronic device 100.

The GPIO interface may be configured by software. The GPIO interface maybe configured as a control signal, or may be configured as a datasignal. In some embodiments, the GPIO interface may be configured toconnect the processor 110 to the camera 193, the display screen 194, thewireless communications module 160, the audio module 170, the sensormodule 180, and the like. The GPIO interface may also be configured asan I2C interface, an I2S interface, a UART interface, a MIPI interface,or the like.

The USB interface 130 is an interface that conforms to USB standardspecifications, and may be specifically a Mini USB interface, a MicroUSB interface, a USB Type C interface, or the like. The USB interfacemay be configured to connect to a charger to charge the electronicdevice 100, or may be configured to transmit data between the electronicdevice 100 and a peripheral device. The USB interface may also beconfigured to connect to a headset to play audio through the headset.The interface may be further configured to connect to another electronicdevice, for example, an AR device.

It should be understood that an interface connection relationshipbetween the modules illustrated in this embodiment of the presentdisclosure is merely an example for description, and does not constitutea limitation on a structure of the electronic device 100. In some otherembodiments of this application, the electronic device 100 mayalternatively use an interface connection manner different from those inthe foregoing embodiment or a combination of a plurality of interfaceconnection manners.

The charging management module 140 is configured to receive a charginginput from a charger. The charger may be a wireless charger, or may be awired charger. In some wired charging embodiments, the chargingmanagement module 140 may receive a charging input from a wired chargerthrough a USB interface. In some wireless charging embodiments, thecharging management module 140 may receive a wireless charging input byusing a wireless charging coil of the electronic device 100. Whencharging the battery 142, the charging management module 140 may furthersupply power to the electronic device by using the power managementmodule 141.

The power management module 141 is configured to connect to the battery142, the charging management module 140, and the processor 110. Thepower management module 141 receives an input from the battery 142and/or the charging management module 140, and supplies power to theprocessor 110, the internal memory 121, an external memory, the displayscreen 194, the camera 193, the wireless communications module 160, andthe like. The power management module 141 may be further configured tomonitor parameters such as a battery capacity, a battery cycle quantity,and a battery health status (leakage and impedance). In some otherembodiments, the power management module 141 may also be disposed in theprocessor 110. In some other embodiments, the power management module141 and the charging management module 140 may also be disposed in asame device.

A wireless communication function of the electronic device 100 may beimplemented by using the antenna module 1, the antenna module 2, themobile communications module 150, the wireless communications module160, the modem processor, the baseband processor, and the like.

The antenna 1 and the antenna 2 are configured to send and receive anelectromagnetic wave signal. Each antenna in the electronic device 100may be configured to cover one or more communications frequency bands.Different antennas may be multiplexed to improve utilization of theantennas. For example, a cellular network antenna may be multiplexedinto a diversity antenna used in a wireless local area network. In someother embodiments, the antenna may be used in combination with a tuningswitch.

The mobile communications module 150 may provide a wirelesscommunications solution that is applied to the electronic device 100 andthat includes 2G, 3G, 4G, 5G, and the like. The mobile communicationsmodule 150 may include at least one filter, a switch, a power amplifier,a low noise amplifier (Low Noise Amplifier, LNA), and the like. Themobile communications module 150 may receive an electromagnetic wave byusing the antenna 1, perform processing such as filtering andamplification on the received electromagnetic wave, and transfer theelectromagnetic wave to the modem processor for demodulation. The mobilecommunications module 150 may also amplify a signal modulated by themodem processor, and convert the signal into an electromagnetic wave andradiate the electromagnetic wave out by using the antenna 1. In someembodiments, at least some functional modules of the mobilecommunications module 150 may be disposed in the processor 110. In someembodiments, at least some functional modules of the mobilecommunications module 150 and at least some modules of the processor 110may be disposed in a same device.

The modem processor may include a modulator and a demodulator. Themodulator is configured to modulate a low frequency baseband signal thatis to be sent into a medium or high frequency signal. The demodulator isconfigured to demodulate a received electromagnetic wave signal into alow frequency baseband signal. Then, the demodulator sends the lowfrequency baseband signal obtained through demodulation to the basebandprocessor for processing. After being processed by the basebandprocessor, the low frequency baseband signal is sent to the applicationprocessor. The application processor outputs a sound signal by using anaudio device (not limited to the speaker 170A, the receiver 170B, andthe like), or displays an image or a video by using the display screen194. In some embodiments, the modem processor may be an independentdevice. In some other embodiments, the modem processor may beindependent of the processor 110, and be disposed in a same device withthe mobile communications module 150 or another functional module.

The wireless communications module 160 may provide a wirelesscommunications solution that is applied to the electronic device 100 andthat includes a wireless local area network (wireless local areanetworks, WLAN), Bluetooth (bluetooth, BT), a global navigationsatellite system (global navigation satellite system, GNSS), frequencymodulation (frequency modulation, FM), a near field wirelesscommunication technology (near field communication, NFC), an infraredtechnology (infrared, IR), and the like. The wireless communicationsmodule 160 may be one or more devices integrating at least onecommunications processing module. The wireless communications module 160receives an electromagnetic wave by using the antenna 2, performsfrequency modulation and filtering processing on an electromagnetic wavesignal, and sends a processed signal to the processor 110. The wirelesscommunications module 160 may also receive a to-be-sent signal from theprocessor 110, perform frequency modulation and amplification on thesignal, and convert the signal into an electromagnetic wave and radiatethe electromagnetic wave out by using the antenna 2. In this embodimentof this application, the wireless communications module 160 isconfigured to send a speech of a first user and a post-translationmachine speech in a target language, or a speech in the target languagesent by a peer user and a post-translation machine speech in a firstlanguage.

In some embodiments, in the electronic device 100, the antenna 1 iscoupled to the mobile communications module 150, and the antenna 2 iscoupled to the wireless communications module 160, so that theelectronic device 100 can communicate with a network and another deviceby using a wireless communications technology. The wirelesscommunications technology may include a global system for mobilecommunications (global system for mobile communications, GSM), a generalpacket radio service (general packet radio service, GPRS), code divisionmultiple access (code division multiple access, CDMA), wideband codedivision multiple access (wideband code division multiple access,WCDMA), time-division code division multiple access (time-division codedivision multiple access, TD-SCDMA), long term evolution (long termevolution, LTE), BT, GNSS, WLAN, NFC, FM, an IR technology, and/or thelike. The GNSS may include a global positioning system (globalpositioning system, GPS), a global navigation satellite system (globalnavigation satellite system, GLONASS), a BeiDou navigation satellitesystem (beidou navigation satellite system, BDS), a quasi-zenithsatellite system (quasi-zenith satellite system, QZSS), and/or asatellite-based enhancement system (satellite based augmentationsystems, SBAS).

The electronic device 100 implements a display function by using theGPU, the display screen 194, the application processor, and the like.The GPU is a microprocessor for image processing, and is connected tothe display screen 194 and the application processor. The GPU isconfigured to perform mathematical and geometric calculation forgraphics rendering. The processor 110 may include one or more GPUs thatexecute program instructions to generate or change display information.

The display screen 194 is configured to display an image, a video, andthe like. The display screen 194 includes a display panel. The displaypanel may use an LCD (liquid crystal display, liquid crystal display),an OLED (organic light-emitting diode, organic light-emitting diode), anactive-matrix organic light-emitting diode or an active-matrix organiclight-emitting diode (active-matrix organic light emitting diode,AMOLED), a flexible light-emitting diode (flex light-emitting diode,FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emittingdiode (quantum dot light emitting diodes, QLED), and the like. In someembodiments, the electronic device 100 may include one or N displayscreens, where N is a positive integer greater than 1. In thisembodiment of this application, the display screen 194 may be configuredto display a call interface, a translation interface, a languagesettings interface, and the like.

The electronic device 100 may implement a photographing function byusing the ISP, the camera 193, the video codec, the GPU, the displayscreen 194, the application processor, and the like.

The ISP is configured to process data fed back by the camera 193. Forexample, during photographing, a shutter is opened, light is transferredto a photosensitive element of a camera by using a lens, an opticalsignal is converted into an electrical signal, and the photosensitiveelement of the camera sends the electrical signal to an ISP forprocessing, so that the electrical signal is converted into an imagevisible to naked eyes. The ISP may also perform algorithm optimizationon image noise, brightness, and a skin color. The ISP may also optimizeparameters such as exposure and a color temperature of a shootingscenario. In some embodiments, the ISP may be disposed in the camera193.

The camera 193 is configured to capture a static image or a video. Anoptical image of an object is generated through a lens and is projectedto a photosensitive element. The photosensitive element may be a chargecoupled device (charge coupled device, CCD) or a complementarymetal-oxide-semiconductor (complementary metal-oxide-semiconductor,CMOS) phototransistor. The photosensitive element converts an opticalsignal into an electrical signal, and then sends the electrical signalto the ISP to convert the electrical signal into a digital image signal.The ISP outputs the digital image signal to the DSP for processing. TheDSP converts the digital image signal into an image signal in a standardformat, such as RGB and YUV. In some embodiments, the electronic device100 may include one or N cameras, where N is a positive integer greaterthan 1.

The digital signal processor is configured to process a digital signal,and may process another digital signal in addition to a digital imagesignal. For example, when the electronic device 100 selects a frequency,the digital signal processor is configured to perform Fourier transformor the like on frequency energy.

The video codec is configured to compress or decompress a digital video.The digital 100 may support one or more types of video codecs. In thisway, the electronic device 100 may play or record videos in a pluralityof encoding formats, for example, MPEG1, MPEG2, MPEG3 and MPEG4.

The NPU is a neural network (neural-network, NN) computing processor. Byreferring to a structure of a biological neural network, for example,referring to a mode of transmission between neurons in a human brain,the NPU quickly processes input information, and may further performself-learning continuously. By using the NPU, an application such asintelligent cognition of the electronic device 100 may be implemented,for example, image recognition, face recognition, voice recognition, andtext understanding.

The external memory interface 120 may be configured to connect to anexternal memory card, for example, a Micro SD card, to extend a storagecapability of the electronic device 100. The external memory cardcommunicates with the processor 110 by using the external memoryinterface 120, to implement a data storage function. For example, filessuch as music and videos are stored in the external memory card.

The internal memory 121 may be configured to store computer executableprogram code, and the executable program code includes an instruction.The processor 110 executes various function applications and dataprocessing of the electronic device 100 by running the instructionstored in the internal memory 121. The memory 121 may include a programstorage area and a data storage area. The program storage area may storean operating system, an application program required by at least onefunction (such as a sound playing function and an image playingfunction), and the like. The data storage area may store data (such asaudio data and a phone book) created when the electronic device 100 isused, and the like. In addition, the memory 121 may include a high-speedrandom access memory, and may further include a nonvolatile memory, forexample, at least one magnetic disk storage device, a flash memorydevice, and universal flash storage (universal flash storage, UFS).

The electronic device 100 may implement an audio function by using theaudio module 170, the speaker 170A, the receiver 170B, the microphone170C, the headset jack 170D, the application processor, and the like,such as music playing and recording.

The audio module 170 is configured to convert digital audio informationinto an analog audio signal for output, and is also configured toconvert an analog audio input into a digital audio signal. The audiomodule 170 may be further configured to encode and decode an audiosignal. In some embodiments, the audio module 170 may be disposed in theprocessor 110, or some functional modules of the audio module 170 aredisposed in the processor 110.

The speaker 170A, also referred to as a “speaker”, is configured toconvert an audio electrical signal into a sound signal. A user maylisten to music or answer a hands-free call by using the speaker 170A ofthe electronic device 100. In this embodiment of this application, thespeaker 170A is configured to play a post-translation machine speech.

The receiver 170B, also referred to as an “earpiece”, is configured toconvert an audio electrical signal into a sound signal. When theelectronic device 100 receives a call or a voice message, a user maylisten to a speech by placing the receiver 170B close to an ear.

The microphone 170C, also referred to as a “microphone” or a“microphone”, is configured to convert a sound signal into an electricalsignal. When making a call or sending a voice message, a user may speakafter moving the microphone 170C close to the mouth, and a sound signalis input to the microphone 170C. At least one microphone 170C may bedisposed in the electronic device 100. In some other embodiments, twomicrophones may be disposed in the electronic device 100, and inaddition to collecting a sound signal, a noise reduction function may befurther implemented. In some other embodiments, three, four, or moremicrophones may be alternatively disposed in the electronic device 100,to implement functions such as collecting a sound signal, reducingnoise, identifying a sound source, and implementing a directionalrecording function. In this embodiment of this application, themicrophone 170C may be configured to collect a speech of a user, forexample, a first speech of a first user in a first language.

The headset jack 170D is configured to connect to a wired headset. Theheadset jack may be a USB interface, or may be a 3.5 mm standardinterface of an open mobile terminal platform (open mobile terminalplatform, OMTP), or a standard interface of the cellulartelecommunications industry association of the USA (cellulartelecommunications industry association of the USA, CTIA).

The pressure sensor 180A is configured to sense a pressure signal, andmay convert the pressure signal into an electrical signal. In someembodiments, the pressure sensor 180A may be disposed in the displayscreen 194. There are many types of pressure sensors 180A, such as aresistive pressure sensor, an inductive pressure sensor, and acapacitive pressure sensor. The capacitive pressure sensor may includeat least two parallel plates that include a conductive material. Whenforce is applied to the pressure sensor 180A, a capacitance betweenelectrodes changes. The electronic device 100 determines a strength ofpressure based on a change in the capacitance. When a touch operation isperformed on the display screen 194, the electronic device 100 detects astrength of the touch operation by using the pressure sensor 180A. Theelectronic device 100 may also calculate a touch position based on adetection signal of the pressure sensor 180A. In some embodiments, touchoperations that are performed on a same touch position but havedifferent touch operation strengths may correspond to differentoperation instructions. For example, when a touch operation whose touchoperation strength is less than a first pressure threshold is performedon a short message application icon, an instruction for viewing a shortmessage is executed. When a touch operation whose touch operationstrength is greater than or equal to the first pressure threshold isperformed on the short message application icon, an instruction forcreating a new short message is executed.

The gyro sensor 180B may be configured to determine a motion posture ofthe electronic device 100. In some embodiments, angular velocities ofthe electronic device 100 around three axes (that is, an x-axis, ay-axis, and a z-axis) may be determined by using the gyro sensor 180B.The gyro sensor 180B may be configured to perform image stabilizationduring photographing. For example, when a shutter is pressed, the gyrosensor 180B detects an angle at which the electronic device 100 shakes,calculates, based on the angle, a distance for which a lens module needsto compensate, and enables a lens to counteract the shake of theelectronic device 100 through a reverse motion, so as to implement imagestabilization. The gyro sensor 180B may be further used in navigationand somatosensory game scenarios.

The barometric pressure sensor 180C is configured to measure barometricpressure. In some embodiments, the electronic device 100 calculates analtitude by using a barometric pressure value measured by the barometricpressure sensor 180C, to assist in positioning and navigation.

The magnetic sensor 180D includes a Hall effect sensor. The electronicdevice 100 may detect opening and closing of a clamshell or a smartcover by using the magnetic sensor 180D. In some embodiments, when theelectronic device 100 is a clamshell device, the electronic device 100may detect opening and closing of a clamshell by using the magneticsensor 180D. Then, a feature such as automatic unlocking of a clamshellis set based on a detected opening/closing state of the smart cover or adetected opening/closing state of the clamshell.

The acceleration sensor 180E may detect magnitudes of accelerations ofthe electronic device 100 in various directions (usually three axes).When the electronic device 100 is static, a magnitude and a direction ofgravity may be detected. The acceleration sensor 180E may be furtherconfigured to recognize a posture of an electronic device, and isapplied to applications such as landscape/portrait orientation switchingand a pedometer.

The distance sensor 180F is configured to measure a distance. Theelectronic device 100 may measure a distance by using infrared or alaser. In some embodiments, in a photographing scenario, the electronicdevice 100 may measure a distance by using the distance sensor 180F, toimplement fast focusing.

The proximity light sensor 180G may include, for example, a lightemitting diode (LED) and an optical detector, for example, a photodiode.The light emitting diode may be an infrared light emitting diode. Theelectronic device 100 emits infrared light to the outside by using thelight emitting diode, and the electronic device 100 detects infraredreflected light from a nearby object by using the photodiode. Whensufficient reflected light is detected, the electronic device 100 maydetermine that there is an object near the electronic device 100. Wheninsufficient reflected light is detected, the electronic device 100 maydetermine that there is no object near the electronic device 100. Theelectronic device 100 may detect, by using the proximity light sensor180G, that a user holds the electronic device 100 close to an ear tomake a call, so as to automatically turn off the screen to save power.The proximity light sensor 180G may also be used in a smart cover modeand a pocket mode to automatically unlock and lock a screen.

The ambient light sensor 180L is configured to sense luminance ofambient light. The electronic device 100 may adaptively adjust luminanceof the display screen 194 based on the sensed luminance of the ambientlight. The ambient light sensor 180L may also be configured toautomatically adjust white balance during photographing. The ambientlight sensor 180L may further cooperate with the proximity light sensor180G to detect whether the electronic device 100 is in a pocket, toprevent an accidental touch.

The fingerprint sensor 180H is configured to collect a fingerprint. Theelectronic device 100 may implement fingerprint unlocking, applicationlock access, fingerprint-based photographing, fingerprint-based callanswering, and the like by using a characteristic of a collectedfingerprint.

The temperature sensor 180J is configured to detect a temperature. Insome embodiments, the electronic device 100 executes a temperatureprocessing policy by using a temperature detected by the temperaturesensor 180J. For example, when a temperature reported by the temperaturesensor 180J exceeds a threshold, the electronic device 100 reducesperformance of a processor near the temperature sensor 180J, to reducepower consumption and implement thermal protection. In some otherembodiments, when a temperature is lower than another threshold, theelectronic device 100 heats the battery 142, to avoid abnormal power-offof the electronic device 100 due to a low temperature. In some otherembodiments, when a temperature is lower than still another threshold,the electronic device 100 boosts an output voltage of the battery 142,to avoid abnormal power-off due to a low temperature.

The touch sensor 180K is also referred to as a “touch panel”. It may bedisposed in the display screen 194, and is configured to detect a touchoperation performed on or near the display screen 194. The detectedtouch operation may be transferred to the application processor todetermine a type of a touch event, and the display screen 194 provides acorresponding visual output. In some other embodiments, the touch sensor180K may alternatively be disposed on a surface of the electronic device100, and a location of the touch sensor 180K is different from alocation of the display screen 194. In this embodiment of thisapplication, the touch panel is configured to receive a first operationand a touch operation such as a confirmation operation, a closeoperation, or an exit operation on a language setting control.

The bone conduction sensor 180M may obtain a vibration signal. In someembodiments, the bone conduction sensor 180M may obtain a vibrationsignal from a vibration bone in a vocal part of a human body. The boneconduction sensor 180M may also be in contact with a human pulse toreceive a blood pressure beating signal. In some embodiments, the boneconduction sensor 180M may also be disposed in a headset. The audiomodule 170 may obtain a voice signal through parsing based on avibration signal that is obtained by the bone conduction sensor 180Mfrom a vibration bone in a vocal part, to implement a speech function.The application processor may parse heart rate information based on ablood pressure beating signal obtained by the bone conduction sensor180M, to implement a heart rate detection function.

The key 190 includes a power key, a volume key, and the like. The keymay be a mechanical key or may be a touch key. The electronic device 100may receive a key input, and generate a key signal input related to auser setting and function control of the electronic device 100.

The motor 191 may generate a vibration prompt. The motor 191 may beconfigured to provide a vibration prompt for an incoming call, or may beconfigured to provide a touch vibration feedback. For example, touchoperations performed on different applications (for example,photographing and audio playing) may correspond to different vibrationfeedback effects. For touch operations performed on different areas ofthe display screen 194, the motor 191 may also correspondingly providedifferent vibration feedback effects. Different application scenarios(for example, time reminder, information receiving, an alarm clock, anda game) may also correspond to different vibration feedback effects. Atouch vibration feedback effect may also be customized.

The indicator 192 may be an indicator, may be configured to indicate acharging status and a battery level change, or may be configured toindicate a message, a missed call, a notification, and the like.

The SIM card interface 195 is configured to connect to a subscriberidentity module (subscriber identity module, SIM). A SIM card may beinserted into the SIM card interface or removed from the SIM cardinterface to implement contact with and separation from the electronicdevice 100. The electronic device 100 may support one or N SIM cardinterfaces, where N is a positive integer greater than 1. The SIM cardinterface 195 may support a nano-SIM card, a micro-SIM card, a SIM card,and the like. A plurality of SIM cards can be inserted into a same SIMcard interface. The plurality of SIM cards may be of a same type, or maybe of different types. The SIM card interface 195 may also be compatiblewith different types of SIM cards. The SIM card interface 195 may alsobe compatible with an external memory card. The electronic device 100interacts with a network by using a SIM card, to implement functionssuch as a call and data communication. In some embodiments, theelectronic device 100 uses an eSIM card, that is, an embedded SIM card.The eSIM card may be embedded in the electronic device 100, and cannotbe separated from the electronic device 100. A software system of theelectronic device 100 may use a layered architecture, an event-drivenarchitecture, a microkernel architecture, a microservice architecture,or a cloud architecture. In this embodiment of the present disclosure,an Android system with a layered architecture is used as an example todescribe a software structure of the electronic device 100.

FIG. 3 is a block diagram of a software structure of an electronicdevice 100 according to an embodiment of the present disclosure.

In the layered architecture, software is divided into several layers,and each layer has clear roles and responsibilities. The layerscommunicate with each other through a software interface. In someembodiments, the Android system is divided into four layers. From top tobottom, they are: an application program layer, an application programframework layer, Android runtime (Android runtime) and a system library,and a kernel layer.

The application program layer may include a series of applicationprogram packages.

As shown in FIG. 3 , the application program packages may includeapplication programs such as phone, camera, gallery, calendar, call,map, navigation, WLAN, Bluetooth, music, video, and short message.

The application program framework layer provides an applicationprogramming interface (application programming interface, API) and aprogramming framework for an application program at the applicationprogram layer. The application program framework layer includes somepredefined functions.

As shown in FIG. 3 , the application program framework layer may includea window manager, a content provider, a view system, a phone manager, aresource manager, a notification manager, and the like.

The window manager is configured to manage a window program. The windowmanager may obtain a size of a display screen, determine whether thereis a status bar, lock the screen, capture the screen, and the like.

The content provider is configured to store and obtain data and to makethe data accessible to an application program. The data may include avideo, an image, audio, calls made and answered, a browsing history anda bookmark, a phone book, and the like.

The view system includes a visualization control, for example, a controlfor displaying a text or a control for displaying a picture. The viewsystem may be configured to build an application program. A displayinterface may include one or more views. For example, a displayinterface including a short message notification icon may include a viewfor displaying a text and a view for displaying a picture.

The phone manager is configured to provide a communication function ofthe electronic device 100, for example, management of a call status(including connected and on-hook).

The resource manager provides various resources for applicationprograms, such as a localized character string, an icon, a picture, alayout file, and a video file.

The notification manager enables an application program to displaynotification information in a status bar. The notification manager maybe configured to convey a notification-type message that automaticallydisappears after a short period of time, without user interaction. Forexample, the notification manager is configured to notify that downloadis completed, provide a message reminder, and the like. Alternatively,the notification manager may be a notification that appears in a statusbar at the top of a system in a form of a chart or a scroll bar text,for example, a notification of an application program running in thebackground, or may be a notification that appears on a screen in a formof a dialog window. For example, text information is prompted in astatus bar, a prompt tone is emitted, an electronic device vibrates, andan indicator blinks.

The Android runtime includes a core library and a virtual machine. TheAndroid runtime is responsible for scheduling and managing an Androidsystem.

The core library includes two parts: One is a performance function thatneeds to be called by a Java language, and the other is an Android corelibrary.

The application program layer and the application program frameworklayer run in the virtual machine. The virtual machine executes Javafiles at the application program layer and the application programframework layer as binary files. The virtual machine is configured toperform functions such as object lifecycle management, stack management,thread management, security and exception management, and garbagecollection.

The system library may include a plurality of functional modules, forexample, a surface manager (surface manager), a media library (MediaLibraries), a three-dimensional graphics processing library (forexample, OpenGL ES), and a 2D graphics engine (for example, SGL).

The surface manager is configured to manage a display subsystem, andcombine 2D and 3D graphic layers for a plurality of applicationprograms.

The media library supports playback and recording of audio and videos ina plurality of commonly used formats, as well as static image files. Themedia library may support a plurality of audio and video encodingformats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

The three-dimensional graphics processing library is configured toimplement three-dimensional graphics drawing, image rendering andcompositing, graphic layer processing, and the like.

The 2D graphics engine is a drawing engine for 2D drawing.

The kernel layer is a layer between hardware and software. The kernellayer includes at least a display driver, a camera driver, an audiodriver, and a sensor driver.

All the following embodiments may be implemented on the electronicdevice 100 that has the foregoing hardware structure. In the followingembodiments, the electronic device 100 is used as an example to describethe translation method provided in the embodiments of this application.

According to the translation method provided in the embodiments of thisapplication, two parties in a call who use different languages canachieve smooth and real-time verbal communication by using a translationfunction of an electronic device. The following describes in detail thetranslation method provided in the embodiments of this application withreference to the accompanying drawings and application scenarios.

Scenario 1

A call between a first electronic device and a second electronic deviceis mainly used as an example. A native language of a first user Wang ofthe first electronic device is Chinese, that is, a first language of thefirst user is Chinese. A native language of a second user Evelyn Choi ofthe second electronic device is English, that is, a target language ofthe first user is English. As shown in FIG. 4A, the first user Wangstarts a phone application of the first electronic device, and calls thesecond user Evelyn Choi on a phone application interface. After the callis connected, because the first user Wang is not proficient in English,the first user Wang chooses to enable a translation function on aninterface in FIG. 4A. In response to a first operation (for example,touching or flicking to the left) performed by the first user Wang on afunction control 401 of translation on a call interface shown in FIG.4A, the first electronic device displays a translation interface shownin FIG. 4B. The translation interface is used to display a text messageand a voice message of both parties in the call.

It should be noted that an electronic device may also automaticallyenable a translation function by monitoring whether languages of twoparties in a call are the same, and display a translation interface. Forexample, the first electronic device detects that the language of thefirst user Wang is Chinese, and the language of the other party, thesecond user Evelyn Choi, is English. Because the two languages aredifferent, the translation function is automatically enabled.

For example, when the first user Wang sends a first speech to the otherparty in Chinese: “Hello, I booked a room from Airbnb, and would like toconfirm the booking information with you.”, the first electronic devicesends the first speech to the second electronic device, and at the sametime automatically recognizes the first speech as a Chinese text anddisplays the Chinese text on the translation interface shown in FIG. 4B.Then, the first electronic device translates the Chinese text into anEnglish text “Hello, I booked a room from Airbnb, and would like toconfirm the booking information with you.”, and displays the Englishtext in an area below the Chinese text on the translation interfaceshown in FIG. 4B. Further, the first electronic device converts theEnglish text into a machine speech in the English language; and aftersending the Chinese speech of the first user Wang to the second userEvelyn Choi, the first electronic device further sends the machinespeech in the English language to the second user Evelyn Choi. In thisway, after the other party, the second user Evelyn Cho, sequentiallyreceives the Chinese speech sent by the first user Wang and the machinespeech in the English language, the second user Evelyn Choi mayunderstand call content of the first user Wang. Then, the second userEvelyn Choi replies with a third speech in English “Sure, from Match 14to 17, 3 nights totally, a single room, right?”. In this case, the firstelectronic device first receives the third speech replied by the seconduser Evelyn Choi, and then the first electronic device automaticallyrecognizes the third speech as a fourth text, and displays the fourthtext on a translation interface shown in FIG. 4C. Then, the firstelectronic device translates the fourth text in English into a fifthtext in Chinese “Sure, from March 14 to 17, three nights in a singleroom, right?”, and displays the Chinese text in an area below the fourthtext “Sure, from Match 14 to 17, 3 nights totally, a single room,right?” on the translation interface shown in FIG. 4B. Further, thefirst electronic device converts the fifth text into a machine speech inthe Chinese language. The first user Wang may understand call content ofthe peer user by reading the Chinese text on the translation interfaceshown in FIG. 4C or by playing the machine speech in the Chineselanguage.

Further, the first user Wang may reply with a Chinese speech “Yes, Iwill check in at 6 o'clock. Thank you.” The first electronic devicefirst automatically recognizes the Chinese speech of the first user Wangas a Chinese text, and displays the Chinese text on a translationinterface shown in FIG. 4D. Then, the first electronic device translatesthe Chinese text into an English text “Yes, I will check in at 6o'clock, thanks.”, and displays the English text in an area below theChinese text “Yes, I will check in at 6 o'clock. Thank you.” on thetranslation interface shown in FIG. 4D. Further, the first electronicdevice converts the English text into a machine speech in the Englishlanguage; and after sending the Chinese speech of the sentence of thefirst user Wang to the second user Evelyn Choi, the first electronicdevice further sends the machine speech in the English language to thesecond user Evelyn Choi. In this way, after the other party, the seconduser Evelyn Choi, receives the Chinese speech replied by the first userWang and the machine speech in the English language, the second userEvelyn Choi may understand call content of the first user Wang, and thesecond user Evelyn Choi replies with an English speech “Got it, You arewelcome.”. In this case, the first electronic device first receives theEnglish speech of the sentence replied by the second user Evelyn Choi,and then the first electronic device first automatically recognizes theEnglish speech of the sentence as an English text, and displays theEnglish text on a translation interface shown in FIG. 4E. Then, thefirst electronic device translates the English text into a Chinese text“Got it. You are welcome.”, and displays the Chinese text after theEnglish text “Got it, You are welcome.” on the translation interfaceshown in FIG. 4E. Further, the first electronic device converts theChinese text into a machine speech in the Chinese language. The firstuser Wang may understand call content of the peer user by reading theChinese text on the translation interface shown in FIG. 4E or by playingthe machine speech in the Chinese language.

On the translation interfaces shown in FIG. 4B to FIG. 4E, thepost-translation texts are displayed on the translation interfaces in aform of messages sent by an AI robot. In addition, on the translationinterfaces shown in FIG. 4B to FIG. 4E, a play icon is marked next to amachine speech currently being played by the first electronic device, asshown by a control 403 in FIG. 4B.

It should be noted that, in addition to a position setting manner of thetranslation control 401 in FIG. 4A, there may be a plurality of positionsetting manners. As shown in FIG. 4F to FIG. 4I, the translation control401 is set in a “More” menu in an upper right corner of a call interfacein FIG. 4F, and the translation control 401 is set in a call controllist in FIG. 4G and FIG. 4H. If the call control list cannot bedisplayed on one screen, a navigation point may be used for flickingdisplay. For example, a floating translation control 401 is set on acall interface in FIG. 4J. When a user flicks to the left on thetranslation control, a display screen may display a translationinterface shown in FIG. 4I.

In addition, it should be noted that, when both the first electronicdevice and the second electronic device have a translation function,both the first electronic device and the second electronic device maydisplay the translation interfaces shown in FIG. 4B to FIG. 4E. When thesecond electronic device does not have a translation function, thesecond electronic device may not display the translation interfacesshown in FIG. 4B to FIG. 4E, and a user understands conversation contentonly by listening to a speech received from the other party and apost-translation machine speech. Alternatively, neither the firstelectronic device nor the second electronic device may display thetranslation interfaces shown in FIG. 4B to FIG. 4E, and a userunderstands conversation content only by using a received speech fromthe other party and a post-translation machine speech.

It should be further noted that, when the electronic device has thetranslation function, the electronic device may be connected to anetwork, and obtain a post-translation text and a post-translationmachine speech from a cloud server by using the network. For example,the electronic device is connected to a wireless fidelity (wirelessfidelity, wifi) network, and obtains a post-translation text and apost-translation machine speech from a cloud server; or the electronicdevice initiates a call by using voice over long term evolution (voiceover long term evolution, VOLTE), and obtains a post-translation textand a post-translation machine speech from a cloud server during thecall. In addition, the translation function may be machine translation,and may also be manual online translation. In addition, the electronicdevice may directly obtain a post-translation text and apost-translation machine speech by using a language library stored inthe electronic device without connecting to a network.

In a possible design, if the first user Wang asks a colleague nearby, athird user Zhang, to manually translate the first user Wang's callcontent, the first user Wang may choose to exit the translationfunction. In this case, when the first electronic device detects anoperation performed by the first user Wang on an exit control 402 (forexample, touching the control 402) shown in FIG. 4B, the firstelectronic device exits the translation interface, and stops translatingcall content of the first user and the peer user at the same time, butthe call continues. For example, after the third user Zhang of the firstelectronic device sends a fifth speech “Thanks.” in English, the firstelectronic device directly sends the fifth speech “Thanks.” to thesecond electronic device. That is, during a call between two users, thetranslation function can be enabled or disabled at any time withoutinterrupting the call. In this way, it is convenient for a user toenable the translation function according to an actual requirement,which is more user-friendly and personalized and improves userexperience.

In another embodiment of this application, as shown in FIG. 5 , if afirst user Wang has an average oral English level and can speak somesimple spoken English, during a call between the first user Wang and asecond user Evelyn Choi, the first user Wang may directly send anEnglish speech during the call. In this case, this sentence does notneed to be translated. Optionally, to achieve this effect, the firstuser Wang may manually disable a function of translating the first userWang's own translation. For example, after the first user Wang sends asecond speech in English “Hello, I booked a room from Airbnb, and wouldlike to confirm the booking information with you.”, in response to adisable operation performed by the first user Wang on a function control501 of “Read my translation” (for example, touching the control 501) ona translation interface shown in FIG. 5 , a first electronic devicedisplays the translation interface shown in FIG. 5 . Only an Englishtext “Hello, I booked a room from Airbnb, and would like to confirm thebooking information with you.” is displayed on the translationinterface. In other words, a user may choose, according to arequirement, whether to translate the user's call content, so as toreduce an invalid translation and improve call fluency. Optionally, evenif a translation switch is turned on, when the first user Wang directlycommunicates with the other party in English, and the first electronicdevice detects that a language used by a local user is English, thefirst electronic device only displays a corresponding English text thatis recognized, and does not translate the recognized English text.

In another embodiment of this application, as shown in FIG. 6 , when afirst user Wang is driving or there is another person around who needsto listen in, the first user Wang may choose to turn on a functionswitch of “Read other party's translation”. For example, a firstelectronic device responds to a turn-on operation performed by the firstuser Wang on a function control 601 of “Read my translation” (forexample, touching the control 601) on a translation interface shown inFIG. 6 ; and after a second user Evelyn Choi sends an English speech“Sure, from Match 14 to 17, 3 nights totally, a single room, right?”,the first electronic device may play a Chinese speech “Sure, from March14 to 17, three nights in a single room, right?” that corresponds to theEnglish speech sent by the second user Evelyn Choi. In other words, auser may choose, according to a requirement, to broadcastpost-translation machine speech content of the other party, which ismore applicable to different service scenarios, and improves userexperience.

In another embodiment of this application, during a call, a user maychoose, according to an actual requirement, to change a language typeafter translation, and the call is not interrupted, that is, the callcontinues. As shown in FIG. 7A to FIG. 7D, when a first electronicdevice detects an operation performed by a first user Wang on a control701 of Set language (for example, touching the control 701) shown inFIG. 7A, a language settings interface shown in FIG. 7B is displayed,where the language settings interface includes language types of twoparties in a call. For example, the language settings interface includesOther party's language and My language, where My language may beobtained in advance by using a system default language. For example, asystem default language of the first electronic device is Chinese.Therefore, as shown in FIG. 7B, My language is Chinese, and Otherparty's language is set to English by default. If a user Wang learns,during a call, that a native language of the other party is French, theuser Wang may immediately change Other party's language to French. Thatis, when detecting an operation performed by the first user Wang on acontrol 702 of Other party's language (for example, touching the control702) on the translation interface shown in FIG. 7B, the first electronicdevice displays a translation interface shown in FIG. 7C. Thetranslation interface includes a plurality of language options. Whendetecting an operation performed by the user on a control 703 of French(for example, touching the control 703), the first electronic devicereturns to the translation interface, that is, a translation interfaceshown in FIG. 7D. The translation interface further includes promptinformation “Switching languages, please wait”. It can be learned that,in the foregoing process, a user can switch a language type during acall, so that the user can communicate smoothly, thereby improvingcommunication efficiency.

In another embodiment of this application, in one manner, before a userestablishes a call, the user may access a language settings interface ofa phone application in advance, that is, the language settings interfaceshown in FIG. 7B, and the user proactively sets Other party's languageand My language. Generally, an electronic device sets, by default, Mylanguage to a system default language, and Other party's language toChinese. The user may modify the default settings according to an actualrequirement. In another manner, when a user establishes a call, anelectronic device may automatically set Other party's language based onan obtained international area code of a phone number dialed by the useror an obtained international area code of an incoming call number. Thatis, the electronic device automatically sets a target language to anofficial language of a country corresponding to the international areacode. For example, an international area code of a call made by a firstuser Wang is 0033, and a first electronic device obtains theinternational area code 0033 and determines that the international areacode belongs to France. Although there is a plurality of languages inFrance, an official language is French. Therefore, the first electronicdevice automatically changes an official language of Other party'slanguage to French. For another example, an international area code ofan incoming call received by a second user Evelyn Choi is 0086, and asecond electronic device obtains the international area code 0086 anddetermines that the international area code belongs to China. Therefore,the second electronic device automatically changes Other party'slanguage to simplified Chinese.

In another embodiment of this application, a specific time delay may becaused during translation, and a first electronic device or a secondelectronic device first converts a speech of a user into a text, andthen translates the text into a machine speech. Therefore, it may bepossible that the original text and a post-translation text are quicklydisplayed on a translation interface, but the other party has notreceived audio data, that is, the other party has not received thepost-translation machine speech. Therefore, a manner of controlling aspeech sequence provided in this embodiment of this application is asfollows: The first electronic device or the second electronic devicefirst displays a text corresponding to a speech sent by a user of thefirst electronic device or the second electronic device; and after thefirst electronic device or the second electronic device obtains, bytranslation, a machine speech corresponding to the speech sent by theuser of the first electronic device or the second electronic device, apost-translation text corresponding to the speech sent by the user ofthe first electronic device or the second electronic device is displayedand a speaker plays the machine speech at the same time. As shown inFIG. 8 , a translation interface first displays “Hello, I booked a roomfrom Airbnb, and would like to confirm the booking information withyou.”. After an electronic device obtains a post-translation machinespeech, the electronic device displays “Hello, I booked a room fromAirbnb, and would like to confirm the booking information with you.”,and at the same time, a speaker broadcasts the machine speech “Hello, Ibooked a room from Airbnb, and would like to confirm the bookinginformation with you.”. It should be noted that the translationinterface may further display a prompt “Got the audio and ready toplay”. In this way, not only speech sequence control can be implemented,but it is also convenient for a user to learn of a current devicestatus.

In another embodiment of this application, when a user speaksexcessively fast, or an interval between consecutive speeches sent bythe user is excessively short, an electronic device may display promptinformation on a translation interface, to remind the user to slow downa speaking rate, so as to avoid overlapping between a machine speech andthe user's speech. For example, as shown in FIG. 9 , a first electronicdevice plays, by using a speaker of the first electronic device, “Sure,from March 14 to 17, three nights in a single room, right?”. Because afirst user Wang has read a post-translation text on a translationinterface before the speaker completes playing a machine speech, thefirst user Wang may send a fourth speech in Chinese “Yes, I will checkin at 6 o'clock. Thank you.”. In this case, the machine speech and thespeech of the first user Wang may overlap. Therefore, in response to thefourth speech, the first electronic device displays prompt information,where the prompt information is used to instruct the first user to senda speech after the machine speech in a first language is played. Asshown in FIG. 9 , a translation interface includes prompt information“Speaking too fast, wait for translation”. Certainly, the promptinformation may not be displayed on the translation interface, and maybe displayed on a display screen by using a separate message box.

In addition, it should be noted that a mute control 901 and a hands-freecontrol 902 are further set on the translation interface shown in FIG. 9. When the electronic device detects an operation performed by a user onthe mute control 901 (for example, touching the control 901), theelectronic device no longer broadcasts speech content. When theelectronic device detects an operation performed by a user on thehands-free control 902 (for example, touching the control 902), theelectronic device no longer plays speech content. In this way, atranslation function may be more user-friendly, thereby improving userexperience.

In some embodiments of this application, an embodiment of thisapplication discloses an electronic device. As shown in FIG. 10 , theelectronic device is configured to implement the method recorded in theforegoing method embodiments, and the electronic device includes areceiving unit 1001, a display unit 1002, a sending unit 1003, and aprocessing unit 1004. The receiving unit 1001 is configured to supportthe electronic device in performing an operation of receiving a user'sspeech and a machine speech in the foregoing method. The display unit1002 is configured to support the electronic device in performing anoperation of displaying a call interface, a translation interface, and acall setting interface in the foregoing method. The sending unit 1003 isconfigured to support the electronic device in performing an operationof sending a user's speech and a machine speech in the foregoing method.The processing unit 1004 is configured to support the electronic devicein converting a speech into a text and translating the speech and thetext into a speech and a text that are in a target language. All relatedcontent in the foregoing method embodiments may be referred to in afunction description of a corresponding unit module, and details are notdescribed herein again.

In some other embodiments of this application, an embodiment of thisapplication discloses an electronic device. As shown in FIG. 11 , theelectronic device may include a touchscreen 1101, one or more processors1102, a memory 1103, one or more application programs (not shown), andone or more computer programs 1104, where the touchscreen 1101 includesa touch panel 1106 and a display screen 1107. The foregoing devices maybe connected by using one or more communications buses 1105. The one ormore computer programs 1104 are stored in the memory 1103 and areconfigured to be executed by the one or more processors 1102. The one ormore computer programs 1104 include an instruction, and the instructionmay be used to perform each step in the corresponding embodiments inFIG. 4A to FIG. 9 .

An embodiment of this application further provides a computer storagemedium. The computer storage medium stores a computer instruction. Whenthe computer instruction runs on an electronic device, the electronicdevice is enabled to perform the foregoing related method steps toimplement the photo sharing method in the foregoing embodiments.

An embodiment of this application further provides a computer programproduct. When the computer program product runs on a computer, thecomputer is enabled to perform the foregoing related steps to implementthe translation method in the foregoing embodiments.

In addition, an embodiment of this application further provides anapparatus. The apparatus may be specifically a chip, a component, or amodule, and the apparatus may include a processor and a memory that areconnected to each other. The memory is configured to store a computerexecutable instruction. When the apparatus runs, the processor mayexecute the computer executable instruction stored in the memory, sothat the chip performs the translation method in the foregoing methodembodiments.

The electronic device, the computer storage medium, the computer programproduct, or the chip provided in the embodiments of this application isconfigured to perform the corresponding method provided above.Therefore, for beneficial effects that can be achieved by the electronicdevice, the computer storage medium, the computer program product, orthe chip, refer to the beneficial effects in the corresponding methodprovided above. Details are not described herein again.

The foregoing descriptions about implementations allow a person skilledin the art to understand that, for the purpose of convenient and briefdescription, division of the foregoing function modules is taken as anexample for illustration. In actual application, the foregoing functionscan be allocated to different modules and implemented according to arequirement, that is, an inner structure of an apparatus is divided intodifferent function modules to implement all or some of the functionsdescribed above.

In the several embodiments provided in this application, it should beunderstood that the disclosed apparatus and method may be implemented inother manners. For example, the described apparatus embodiment is merelyan example. For example, the module or unit division is merely logicalfunction division and may be other division in actual implementation.For example, a plurality of units or components may be combined orintegrated into another apparatus, or some features may be ignored ornot performed. In addition, the displayed or discussed mutual couplingsor direct couplings or communication connections may be implementedthrough some interfaces. The indirect couplings or communicationconnections between the apparatuses or units may be implemented inelectronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may be one or more physicalunits, may be located in one place, or may be distributed in differentplaces. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit. Theintegrated unit may be implemented in a form of hardware, or may beimplemented in a form of a software functional unit.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a readable storage medium. Based onsuch an understanding, the technical solutions of this applicationessentially, or the part contributing to the prior art, or all or someof the technical solutions may be implemented in the form of a softwareproduct. The software product is stored in a storage medium and includesseveral instructions for instructing a device (which may be asingle-chip microcomputer, a chip or the like) or a processor(processor) to perform all or some of the steps of the methods describedin the embodiments of this application. The foregoing storage mediumincludes: any medium that can store program code, such as a USB flashdrive, a removable hard disk, a read-only memory (read-only memory,ROM), a random access memory (random access memory, RAM), a magneticdisk, or an optical disc.

The foregoing descriptions are merely specific implementations of thisapplication, but are not intended to limit the protection scope of thisapplication. Any variation or replacement readily figured out by aperson skilled in the art within the technical scope disclosed in thisapplication shall fall within the protection scope of this application.Therefore, the protection scope of this application shall be subject tothe protection scope of the claims.

What is claimed is:
 1. A translation method implemented by a first electronic device, wherein the translation method comprises: establishing a call connection to a second electronic device; displaying a call interface of the first electronic device during the call connection; receiving a first operation from a user; switching, in response to the first operation, from displaying the call interface to displaying a translation interface; receiving first speech from the user in a first language; displaying, using the translation interface and in response to receiving the first speech, a first text and a second text, wherein the first text is based on the first speech, and wherein the second text is in a target language; sending a first machine speech in the target language to the second electronic device, wherein the first machine speech is a translation of the first speech into the target language; receiving, on the translation interface, a language setting operation from the user; switching, in response to the language setting operation, from displaying the translation interface to displaying a language settings interface, wherein the language settings interface comprises a setting control of a second language; receiving, on the setting control, a confirmation operation from the user; setting, in response to receiving the confirmation operation, the target language to the second language; receiving, on the call interface, an on-hook operation from the user; and terminating the call connection in response to the on-hook operation.
 2. The translation method of claim 1, further comprising: obtaining an international area code from a phone number dialed by the user, wherein the phone number is for establishing the call connection; and setting, based on the international area code, the target language to an official language of a country corresponding to the international area code.
 3. The translation method of claim 1, wherein after receiving the first speech, the translation method further comprises: obtaining the first text by recognizing the first speech; translating the first text into the second text; and converting the second text into the first machine speech.
 4. The translation method of claim 1, further comprising: receiving second speech of the user in the target language; recognizing the second speech to obtain a third text in the target language; determining that the second speech is in the target language; skipping, in response to determining that the second speech is in the target language, translating the second speech; and displaying the third text on the translation interface.
 5. The translation method of claim 1, wherein after sending the first machine speech to the second electronic device and before receiving the on-hook operation, the translation method further comprises: receiving, from the second electronic device, second speech that is in the target language; recognizing the second speech to obtain a third text in the target language; translating the second speech to obtain a fourth text in the first language; displaying, in response to translating the second speech, the third text and the fourth text in the translation interface; obtaining a second machine speech in the first language by translating the second speech into the first language; and playing the second machine speech.
 6. The translation method of claim 5, further comprising: playing, using an earpiece of the first electronic device, the second speech; and playing, using a speaker of the first electronic device and after receiving the second machine speech and before receiving the on-hook operation, the second machine speech in the first language.
 7. The translation method of claim 6, wherein when playing the second machine speech, the translation method further comprises: receiving a third speech of the user in the first language; and displaying, in response to receiving the third speech, prompt information that instructs the user to send a fourth speech after the second machine speech is played.
 8. The translation method of claim 1, wherein the translation method further comprises obtaining the first text, the second text, or the first machine speech from a cloud server through a communication connection between the first electronic device and the cloud server.
 9. The translation method of claim 1, wherein before receiving the on-hook operation, the method further comprises: receiving, on the translation interface, an exit operation from the user; switching, in response to receiving the exit operation, from displaying the translation interface to displaying the call interface; receiving a second speech of the user in the first language; and sending the second speech to the second electronic device.
 10. A first electronic device, comprising: a memory configured to store instructions; a processor coupled to the memory and configured to execute the instructions to cause the first electronic device to: establish a call connection to a second electronic device; display a call interface during the call connection; receive a first operation from a user; switch, in response to receiving the first operation, from displaying the call interface to displaying a translation interface; receive first speech from the user in a first language; display, using the translation interface and in response to receiving the first speech, a first text and a second text, wherein the first text is based on the first speech, and wherein the second text is in a target language; send a first machine speech in the target language to the second electronic device, wherein the first machine speech is a translation of the first speech into the target language; receive, on the translation interface, a language setting operation from the user; switch, in response to receiving the language setting operation, from displaying the translation interface to displaying a language settings interface, wherein the language settings interface comprises a setting control of a second language; receive, on the setting control of the second language, a confirmation operation from the user; set, in response to receiving the confirmation operation, the target language to the second language; receive, on the call interface, an on-hook operation from the user; and terminate the call connection in response to the on-hook operation.
 11. The first electronic device of claim 10, wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: obtain an international area code from a phone number dialed by the user, wherein the phone number is for establishing the call connection; and set, based on the international area code, the target language to an official language of a country corresponding to the international area code.
 12. The first electronic device of claim 10, wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: obtain the first text by recognizing the first speech; translate the first text into the second text; and convert the second text into the first machine speech.
 13. The first electronic device of claim 10, wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: receive second speech of the user in the target language; recognize the second speech to obtain a third text in the target language; determine that the second speech is in the target language; skip, in response to determining that the second speech is in the target language, translating the second speech; and display the third text on the translation interface.
 14. The first electronic device of claim 10, wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: receive second speech from the second electronic device; recognize the second speech to obtain a third text in the target language; translate the second speech to obtain a fourth text in the first language; display, in response to translating the second speech, the third text and the fourth text in the translation interface; obtain a second machine speech in the first language by translating the second speech into the first language; and play the second machine speech.
 15. The first electronic device of claim 14, further comprising an earpiece coupled to the processor, and wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: play, using the earpiece, the second speech; and play the second machine speech.
 16. The first electronic device of claim 15, wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: receive a close operation from the user; and stop playing, in response to the close operation, the second machine speech.
 17. The first electronic device of claim 15, wherein when executed by the processor, the instructions further cause the first electronic device to be configured to: receive a third speech of the user in the first language; and display, in response to receiving the third speech, prompt information that instructs the user to send a fourth speech after the second machine speech is played.
 18. The first electronic device of claim 10, wherein before the instructions cause the first electronic device to receive the on-hook operation, when executed by the processor, the instructions further cause the first electronic device to be configured to: receive an exit operation from the user; switch, in response to receiving the exit operation, from displaying the translation interface to displaying the call interface; receive a second speech of the user in the first language; and send the second speech to the second electronic device.
 19. A computer program product comprising instructions that are stored on a non-transitory computer-readable medium and that, when executed by a processor, cause a first electronic device to: establish a call connection to a second electronic device; display a call interface of the first electronic device during the call connection; receive a first operation from a user; switch, in response to the first operation, from displaying the call interface to displaying a translation interface; receive, from the user, first speech in a first language; display, using the translation interface and in response to receiving the first speech, a first text and a second text, wherein the first text is based on the first speech, and wherein the second text is in a target language; send a first machine speech in the target language to the second electronic device, wherein the first machine speech is a translation of the first speech into the target language; receive, on the translation interface, a language setting operation from the user; switch, in response to the language setting operation, from displaying the translation interface to displaying a language settings interface, wherein the language settings interface comprises a setting control of a second language; receive, on the setting control of the second language, a confirmation operation from the user; set, in response to the confirmation operation, the target language to the second language; receive, on the call interface, an on-hook operation from the user; and terminate the call connection in response to the on-hook operation.
 20. The computer program product of claim 19, wherein when executed by the processor, the instructions further cause the first electronic device to: receive second speech of the user in the target language; recognize the second speech to obtain a third text in the target language; determine that the second speech is in the target language; skip, in response to determining that the second speech is in the target language, translating the second speech; and display the third text on the translation interface. 